package com.zzw.hj32;

import java.util.Scanner;

/**
 * @Project: hw_java
 * @Description: 密码截取
 * @Author: zzw
 */
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            // 动规--确定回文串的最大长度
            String code = in.nextLine();
            int len = code.length();
            if (len == 1) {
                System.out.println(1);
            }

            // dp[i][j] - 目标字符串i到j是否为回文串， i>j为false i=j为true
            // 状态转移方程
            // dp[i][j] = dp[i+1][j-1] || charAt(i) == charAt(j) (j-i>1)
            // dp[i][j] = charAt(i) == charAt(j) (j-i=1)
            // 答案-dp[i][j] = true , max(j-i+1)
            boolean[][] dp = new boolean[len][len];
            int maxLen = 1;
            for (int i = 0; i < len; i++) // j=i边界条件
                dp[i][i] = true;

            for (int l = 2; l <= len;
                 l++) { // 循环条件为子串长度，子串长度由短至长
                for (int i = 0; (i + l - 1) < len; i++) {
                    int j = i + l - 1;
                    if (code.charAt(i) == code.charAt(j)) {
                        if (l == 2)
                            dp[i][j] = true;
                        else
                            dp[i][j] = dp[i + 1][j - 1];
                    }
                    if (dp[i][j] == true)
                        maxLen = Math.max(maxLen, l);
                }
            }
            System.out.println(maxLen);
        }
    }
}